//
//  BelowView.m
//  B段项目
//
//  Created by 昶博 on 15/9/24.
//  Copyright (c) 2015年 昶博. All rights reserved.
//

#import "BelowView.h"
#import "DetailViewController.h"
#import "Player.h"
#import <UIImageView+WebCache.h>
#import "ForthView.h"

@interface BelowView ()

@end

@implementation BelowView
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
           
    if (self) {
        
         
       self.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap)];
        [self addGestureRecognizer:tap];
        
        // 转动的图片
        
        Player *player = [Player  share];
        
        self.imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10*w, 15*h, 70*w, 70*h)];
       

        if (player.Pic == nil) {
          
          self.imageView.image = [UIImage imageNamed:@"44.jpg"];
                }
       else
       {
           [self.imageView sd_setImageWithURL:[NSURL URLWithString:[Player share].Pic] placeholderImage:[UIImage imageNamed:@"44"]];
           
       }
     
        self.imageView.backgroundColor = [UIColor redColor];
        self.imageView.layer.cornerRadius = 35*h;
        self.imageView.layer.masksToBounds = YES;
        [self addSubview:self.imageView];
        
       self.button = [UIButton buttonWithType:UIButtonTypeCustom];
        self.button.frame = CGRectMake(310*w, 35*h, 35*w, 35*h);
        
            [self.button setBackgroundImage:[UIImage imageNamed:@"bofanbai"] forState:UIControlStateNormal];
  
    [self.button addTarget:self action:@selector(BoFangclicked:) forControlEvents:UIControlEventTouchUpInside];
      [self addSubview:self.button];
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(90*w, 19*h, 200*w, 20*h)];
        self.titleLabel.textColor = [UIColor whiteColor];
        [self addSubview:self.titleLabel];
        
        self.label = [[UILabel alloc]initWithFrame:CGRectMake(90*w, 60*h, 100*w, 20*h)];
        self.label.textColor = [UIColor whiteColor];
        [self addSubview:self.label];
        if ([Player share].titleLabel == nil ) {
             
        }
        else
        {
            self.titleLabel.text = [Player share].titleLabel;
            self.label.text = [Player share].label;
        }
           
    }
    
    return self;
    
}
-(void)tap
{
  
    
//    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
//  
//
//     
//    [center postNotificationName:@"change" object:[Player share].model];
 
}
-(void)BoFangclicked:(UIButton *)button
{
 
    
    
    button.selected = !button.selected;
   
    if (  button.selected == 1) {
        [self.button setBackgroundImage:[UIImage imageNamed:@"bofanbai"] forState:UIControlStateNormal];
        
         [[Player share]pause];
    
        

             }
    else
    {
        
        [self.button setBackgroundImage:[UIImage imageNamed:@"zantibai"] forState:UIControlStateNormal];
        
        [[Player share] resume];

    
    }
    
}










/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
